package com.demo.cloud.server.controller;

import com.demo.cloud.autoconfig.starter.service.LuckyNumberService;
import com.demo.cloud.server.apis.DemoServicesApis;
import com.demo.cloud.server.service.DemoServices;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/test")
@RefreshScope
public class DemoController {
    /**自定义starter接口*/
    @Autowired
    private LuckyNumberService luckyNumberService;
    /**普通接口*/
    @Autowired
    private DemoServices testServices;
    /**feign客户端：接口引用*/
    @Autowired
    private DemoServicesApis demoServicesApis;
    /**config配置中心文件参数*/
    @Value("${dev.age}")
    private String age;

    @RequestMapping("/demo")
    public String get(String name) {

        String str = luckyNumberService.getLuckyNum(name);
        String param = testServices.get(name);
        String apiParam = demoServicesApis.get("api params!");
        return apiParam + "<br>" + param + "<hr>" + str + "<br><hr> 年龄：" + age;
    }
}
